﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using DaInterFace;
using DaInterFace.Mobile;

namespace J03
{
    //所有订单信息
    public class A01 : IMobileChild
    {
        public string Code(IMobile handler, ClientUser user, String parameter)
        {
            string strResult = "";
            int nCount = 1;
            int nTotalPages = 0;
            // Dictionary<string, SalesOrderInfor> ht = new Dictionary<string, SalesOrderInfor>();
            List<SalesOrderInfor> ht = new List<SalesOrderInfor>();

            FunctionParameter fp = new FunctionParameter();

            fp = (FunctionParameter)handler.Json.JsonToClass(parameter, typeof(FunctionParameter));

            SqlParameter[] sps = new SqlParameter[3];
            sps[0] = new SqlParameter("@FBillNo", SqlDbType.NChar, 50);
            sps[0].Value = user.UserName;
            sps[1] = new SqlParameter("@StartTime", SqlDbType.NChar, 50);
            sps[1].Value = fp.StartTime;
            sps[2] = new SqlParameter("@EndTime", SqlDbType.NChar, 50);
            sps[2].Value = fp.EndTime;

            //string strSQL = "select A.FID 订单FID,A.FBillNo 订单编号,D.FName 客户,B.FName 产品,A.FDecimal 数量,A.FDecimal3 含税单价,A.FDecimal7 含税运价,A.FDecimal8 运输金额,A.FDecimal4 含税金额,A.FDecimal9 总金额,A.FDate 下单日期,A.FDecimal10 已用数量,A.FDecimal12 已用金额,A.FDecimal5 运输单价,A.FDecimal6 运费税率,A.FDecimal1 单价,A.FDecimal2 税率,F.FName 袋装标准,G.FName 计量方案,A.FDecimal11 余量,C.FName 业务员,A.FDecimal13 其它单价,A.FDecimal14 其它金额,H.FName 销售方式,E.FName 结算方式 from KEW_SaleOrderQty A ";
            //strSQL = strSQL + "left join KEW_Products B on B.FID=A.FBase4 ";
            string strSQL = "select A.FID 订单FID,A.FBillNo 订单编号,D.FName 客户,B.FName 产品,A.FDecimal 数量,A.FDecimal3 含税单价,A.FDecimal7 含税运价,A.FDecimal8 运输金额,A.FDecimal4 含税金额,A.FDecimal9 总金额,A.FDate 下单日期,A.FDecimal10 已用数量,A.FDecimal12 已用金额,A.FDecimal5 运输单价,A.FDecimal6 运费税率,A.FDecimal1 单价,A.FDecimal2 税率,F.FName 袋装标准,G.FName 计量方案,A.FDecimal11 余量,C.FName 业务员,A.FDecimal13 其它单价,A.FDecimal14 其它金额,H.FName 销售方式,E.FName 结算方式 ,B.FCheckBox 是否袋装,F.FDecimal 每袋重量,B.FID 产品FID from KEW_SaleOrderQty A ";
            strSQL = strSQL + "left join KEW_ProductsEntry B on B.FID=A.FBase4 ";
            strSQL = strSQL + "left join t_Emp C on C.FItemID=A.FBase6 ";
            strSQL = strSQL + "left join t_Organization D on D.FItemID=A.FBase ";
            strSQL = strSQL + "left join t_Settle E on E.FItemID=A.FBase8 ";
            // strSQL = strSQL + "left join KEW_ProductsBagRule F on F.FParentID=A.FBase3 ";
            strSQL = strSQL + "left join KEW_ProductsBagRuleEntry F on F.FID=A.FBase3 ";
            strSQL = strSQL + "left join KEW_SalesConfig G on G.FID=A.FBase5 ";
            strSQL = strSQL + "left join t_SubMessage H on H.FInterID=A.FComboBox1 ";
            strSQL = strSQL + "left join KEW_SalesGuests I on I.FID=A.FID_SRC ";
            strSQL = strSQL + "where I.FBillNo=@FBillNo and (A.FDate>=@StartTime or @StartTime='') and (A.FDate<=@EndTime or @EndTime='') and A.FMultiCheckStatus='16' and A.FCheckBox=0 order by A.FID desc";


            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                strResult = "";
                return strResult;
            }

            if (rs.Data.Tables[0].Rows.Count % fp.PageSize == 0)
            {
                nTotalPages = rs.Data.Tables[0].Rows.Count / fp.PageSize;
            }
            else
            {
                nTotalPages = rs.Data.Tables[0].Rows.Count / fp.PageSize + 1;
            }

            foreach (DataTable dt in rs.Data.Tables)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    if ((fp.PageSize * fp.Page >= nCount) && ((fp.Page - 1) * fp.PageSize < nCount))
                    {
                        SalesOrderInfor orderInfor = new SalesOrderInfor();
                        orderInfor.FID = dr[0].ToString();
                        orderInfor.FBillNo = dr[1].ToString();
                        orderInfor.ClientName = dr[2].ToString();
                        orderInfor.ProductName = dr[3].ToString();
                        orderInfor.Amount = Math.Round(Common.CDec(dr[4].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.TaxPrice = Math.Round(Common.CDec(dr[5].ToString()), Common.PricePrecision).ToString();
                        orderInfor.TaxTransatePrice = Math.Round(Common.CDec(dr[6].ToString()), Common.PricePrecision).ToString();
                        orderInfor.TransateMoney = Math.Round(Common.CDec(dr[7].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.TaxMoney = Math.Round(Common.CDec(dr[8].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.TotalMoney = Math.Round(Common.CDec(dr[9].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.OrderDate = dr[10].ToString();
                        orderInfor.UsedNumber = Math.Round(Common.CDec(dr[11].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.UsedMoney = Math.Round(Common.CDec(dr[12].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.TransatePrice = Math.Round(Common.CDec(dr[13].ToString()), Common.PricePrecision).ToString();
                        orderInfor.TaxTransateRate = Math.Round(Common.CDec(dr[14].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.Price = Math.Round(Common.CDec(dr[15].ToString()), Common.PricePrecision).ToString();
                        orderInfor.TaxRate = Math.Round(Common.CDec(dr[16].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.BagStandard = dr[17].ToString();
                        orderInfor.MeasurementPlan = dr[18].ToString();
                        orderInfor.Allowance = Math.Round(Common.CDec(dr[19].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.SalesMan = dr[20].ToString();
                        orderInfor.OtherPrice = Math.Round(Common.CDec(dr[21].ToString()), Common.PricePrecision).ToString();
                        orderInfor.OtherMoney = Math.Round(Common.CDec(dr[22].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.SalesWay = dr[23].ToString();
                        orderInfor.SettleWay = dr[24].ToString();
                        orderInfor.IsBag = dr[25].ToString();
                        orderInfor.BagWeight = dr[26].ToString();
                        orderInfor.ProFID = dr[27].ToString();
                        orderInfor.TotalPages = nTotalPages;
                        ht.Add(orderInfor);

                    }

                    if (nCount == fp.PageSize * fp.Page)
                    {
                        break;
                    }
                    nCount++;
                }
            }

            strResult = handler.Json.ClassToJson(ht);
            return strResult;
        }
    }

    //所有订单信息
    public class A02 : IMobileChild
    {
        public string Code(IMobile handler, ClientUser user, String parameter)
        {
            string strResult = "";
            // Dictionary<string, SalesOrderInfor> ht = new Dictionary<string, SalesOrderInfor>();
            List<SalesOrderInfor> ht = new List<SalesOrderInfor>();
            FunctionParameter fp = new FunctionParameter();

            fp = (FunctionParameter)handler.Json.JsonToClass(parameter, typeof(FunctionParameter));

            SqlParameter[] sps = new SqlParameter[1];
            sps[0] = new SqlParameter("@FID", SqlDbType.NChar, 50);
            sps[0].Value = fp.OrderFID;

            string strSQL = "select A.FID 订单FID,A.FBillNo 订单编号,D.FName 客户,B.FName 产品,A.FDecimal 数量,A.FDecimal3 含税单价,A.FDecimal7 含税运价,A.FDecimal8 运输金额,A.FDecimal4 含税金额,A.FDecimal9 总金额,A.FDate 下单日期,A.FDecimal10 已用数量,A.FDecimal12 已用金额,A.FDecimal5 运输单价,A.FDecimal6 运费税率,A.FDecimal1 单价,A.FDecimal2 税率,F.FName 袋装标准,G.FName 计量方案,A.FDecimal11 余量,C.FName 业务员,A.FDecimal13 其它单价,A.FDecimal14 其它金额,H.FName 销售方式,E.FName 结算方式 from KEW_SaleOrderQty A ";
            strSQL = strSQL + "left join KEW_Products B on B.FID=A.FBase4 ";
            strSQL = strSQL + "left join t_Emp C on C.FItemID=A.FBase6 ";
            strSQL = strSQL + "left join t_Organization D on D.FItemID=A.FBase ";
            strSQL = strSQL + "left join t_Settle E on E.FItemID=A.FBase8 ";
            strSQL = strSQL + "left join KEW_ProductsBagRule F on F.FParentID=A.FBase3 ";
            strSQL = strSQL + "left join KEW_SalesConfig G on G.FID=A.FBase5 ";
            strSQL = strSQL + "left join t_SubMessage H on H.FInterID=A.FComboBox1 ";
            strSQL = strSQL + "left join KEW_SalesGuests I on I.FID=A.FID_SRC ";
            strSQL = strSQL + "where A.FID=@FID and A.FMultiCheckStatus='16' and A.FCheckBox=0 order by A.FID desc";


            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                strResult = "";
                return strResult;
            }

            foreach (DataTable dt in rs.Data.Tables)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    SalesOrderInfor orderInfor = new SalesOrderInfor();
                    orderInfor.FID = dr[0].ToString();
                    orderInfor.FBillNo = dr[1].ToString();
                    orderInfor.ClientName = dr[2].ToString();
                    orderInfor.ProductName = dr[3].ToString();
                    orderInfor.Amount = Math.Round(Common.CDec(dr[4].ToString()), Common.AmountPrecision).ToString();
                    orderInfor.TaxPrice = Math.Round(Common.CDec(dr[5].ToString()), Common.PricePrecision).ToString();
                    orderInfor.TaxTransatePrice = Math.Round(Common.CDec(dr[6].ToString()), Common.PricePrecision).ToString();
                    orderInfor.TransateMoney = Math.Round(Common.CDec(dr[7].ToString()), Common.AmountPrecision).ToString();
                    orderInfor.TaxMoney = Math.Round(Common.CDec(dr[8].ToString()), Common.AmountPrecision).ToString();
                    orderInfor.TotalMoney = Math.Round(Common.CDec(dr[9].ToString()), Common.AmountPrecision).ToString();
                    orderInfor.OrderDate = dr[10].ToString();
                    orderInfor.UsedNumber = Math.Round(Common.CDec(dr[11].ToString()), Common.QtyPrecision).ToString();
                    orderInfor.UsedMoney = Math.Round(Common.CDec(dr[12].ToString()), Common.AmountPrecision).ToString();
                    orderInfor.TransatePrice = Math.Round(Common.CDec(dr[13].ToString()), Common.PricePrecision).ToString();
                    orderInfor.TaxTransateRate = Math.Round(Common.CDec(dr[14].ToString()), Common.AmountPrecision).ToString();
                    orderInfor.Price = Math.Round(Common.CDec(dr[15].ToString()), Common.PricePrecision).ToString();
                    orderInfor.TaxRate = Math.Round(Common.CDec(dr[16].ToString()), Common.AmountPrecision).ToString();
                    orderInfor.BagStandard = dr[17].ToString();
                    orderInfor.MeasurementPlan = dr[18].ToString();
                    orderInfor.Allowance = Math.Round(Common.CDec(dr[19].ToString()), Common.AmountPrecision).ToString();
                    orderInfor.SalesMan = dr[20].ToString();
                    orderInfor.OtherPrice = Math.Round(Common.CDec(dr[21].ToString()), Common.PricePrecision).ToString();
                    orderInfor.OtherMoney = Math.Round(Common.CDec(dr[22].ToString()), Common.AmountPrecision).ToString();
                    orderInfor.SalesWay = dr[23].ToString();
                    orderInfor.SettleWay = dr[24].ToString();
                    ht.Add(orderInfor);

                }
            }

            strResult = handler.Json.ClassToJson(ht);
            return strResult;
        }
    }

    //所有销售车辆
    public class A03 : IMobileChild
    {
        public string Code(IMobile handler, ClientUser user, string parameter)
        {
            string strResult = "";
            int nCount = 1;
            int nTotalPages = 0;
            string strQuery = "";
            //Dictionary<string, SalesCarInfor> ht = new Dictionary<string, SalesCarInfor>();
            List<SalesCarInfor> ht = new List<SalesCarInfor>();
            FunctionParameter fp = new FunctionParameter();

            fp = (FunctionParameter)handler.Json.JsonToClass(parameter, typeof(FunctionParameter));

            SqlParameter[] sps = new SqlParameter[5];
            sps[0] = new SqlParameter("@FID", SqlDbType.NChar, 50);
            sps[0].Value = fp.OrderFID;
            sps[1] = new SqlParameter("@FBillNo", SqlDbType.NChar, 50);
            sps[1].Value = user.UserName;
            sps[2] = new SqlParameter("@StartTime", SqlDbType.NChar, 50);
            sps[2].Value = fp.StartTime;
            sps[3] = new SqlParameter("@EndTime", SqlDbType.NChar, 50);
            sps[3].Value = fp.EndTime;
            sps[4] = new SqlParameter("@CalStatus", SqlDbType.Int);
            sps[4].Value = fp.CalStatus;

            string strSQL = "select distinct(A.FID) 车辆FID,A.FBillNo 过磅编号,A.FText 车牌号码,A.FDecimal4 计划预装,A.FDecimal 进厂重量,A.FDecimal1 出厂重量,A.FDecimal2 实际净重,A.FDecimal3 出库数量,A.FComboBox 称量状态,A.FComboBox2 过磅类型,A.FTime 开票时间,A.FTime1 进厂时间,A.FTime2 出厂时间,A.FText8 磁卡,A.FText12 发货授权编号,B.FName 客户,C.FName 产品,A.FText1 开票人员,A.FText2 进厂司磅,A.FText3 出厂司磅,A.FDecimal19 盈亏,A.FText9 签发人员,D.FName 销售车辆,A.FComboBox3 生产线, A.FCheckBox4 作废标志 from KEW_SalesInfo A ";
            strSQL = strSQL + "left join t_Organization B on B.FItemID=A.FBase1 ";
            strSQL = strSQL + "left join KEW_Products C on C.FID=A.FBase ";
            strSQL = strSQL + "left join KEW_SalesCar D on D.FID=A.FBase3 ";
            strSQL = strSQL + "left join KEW_SalesInfoEntry E on E.FID=A.FID ";
            strSQL = strSQL + "left join KEW_SaleOrderQty F on F.FID=E.FID_SRC ";
            strSQL = strSQL + "left join KEW_SalesGuests G on G.FID=F.FID_SRC ";
            strSQL = strSQL + "where (F.FID=@FID or @FID='') and G.FBillNo=@FBillNo and (A.FTime2>=@StartTime or @StartTime='') and (A.FTime2<=@EndTime or @EndTime='')and ((A.FCheckBox4=case when  (@CalStatus= 4 and @CalStatus<> -100)then 1 else 0 end) or(A.FCheckBox4!=case when @CalStatus= -100 then '' end)) and ((A.FComboBox=case when (@CalStatus<> -100 and @CalStatus<>4) then @CalStatus end) or (A.FComboBox!=case when (@CalStatus= -100 or @CalStatus=4) then '' end)) order by A.FID desc";

            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                strResult = "";
                return strResult;
            }

            if (rs.Data.Tables[0].Rows.Count % fp.PageSize == 0)
            {
                nTotalPages = rs.Data.Tables[0].Rows.Count / fp.PageSize;
            }
            else
            {
                nTotalPages = rs.Data.Tables[0].Rows.Count / fp.PageSize + 1;
            }

            foreach (DataTable dt in rs.Data.Tables)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    if ((fp.PageSize * fp.Page >= nCount) && ((fp.Page - 1) * fp.PageSize < nCount))
                    {
                        SalesCarInfor orderInfor = new SalesCarInfor();
                        orderInfor.FID = dr[0].ToString();
                        orderInfor.WeighNumber = dr[1].ToString();
                        orderInfor.CarNumber = dr[2].ToString();
                        orderInfor.PreviousPlan = Math.Round(Common.CDec(dr[3].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.InWeight = Math.Round(Common.CDec(dr[4].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.OutWeight = Math.Round(Common.CDec(dr[5].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.FactNetWeight = Math.Round(Common.CDec(dr[6].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.OutStorage = Math.Round(Common.CDec(dr[7].ToString()), Common.QtyPrecision).ToString();

                        strQuery = dr[8].ToString().Trim();
                        if (Convert.ToInt32(strQuery) == 0)
                        {
                            orderInfor.WeighStatues = "开票";
                        }
                        else if (Convert.ToInt32(strQuery) == 1)
                        {
                            orderInfor.WeighStatues = "已开票";
                        }
                        else if (Convert.ToInt32(strQuery) == 2)
                        {
                            orderInfor.WeighStatues = "已进厂计量";
                        }
                        else if (Convert.ToInt32(strQuery) == 3)
                        {
                            orderInfor.WeighStatues = "计量完成";
                        }
                        else if (Convert.ToInt32(strQuery) == -1)
                        {
                            orderInfor.WeighStatues = "已发货授权";
                        }

                        strQuery = dr[24].ToString().Trim();
                        if (Convert.ToBoolean(strQuery))
                        {
                            orderInfor.WeighStatues = "已作废";
                        }

                        strQuery = dr[9].ToString().Trim();
                        if (Convert.ToInt32(strQuery) == 0)
                        {
                            orderInfor.WeighType = "正常过磅";
                        }
                        else if (Convert.ToInt32(strQuery) == 1)
                        {
                            orderInfor.WeighType = "退货";
                        }
                        else if (Convert.ToInt32(strQuery) == 2)
                        {
                            orderInfor.WeighType = "空车出厂";
                        }

                        orderInfor.TicketTime = dr[10].ToString();
                        orderInfor.InTime = dr[11].ToString();
                        orderInfor.OutTime = dr[12].ToString();
                        orderInfor.CardNum = dr[13].ToString();
                        orderInfor.OrderNumber = dr[14].ToString();
                        orderInfor.ClientName = dr[15].ToString();
                        orderInfor.ProductName = dr[16].ToString();
                        orderInfor.BillingMan = dr[17].ToString();
                        orderInfor.InSiBang = dr[18].ToString();
                        orderInfor.OutSiBang = dr[19].ToString();
                        orderInfor.ProfitAndLoss = Math.Round(Common.CDec(dr[20].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.SignMan = dr[21].ToString();
                        orderInfor.SalesCar = dr[22].ToString();
                        orderInfor.ProduceNumber = dr[23].ToString();
                        orderInfor.TotalPages = nTotalPages;
                        ht.Add(orderInfor);
                    }

                    if (nCount == fp.PageSize * fp.Page)
                    {
                        break;
                    }
                    nCount++;
                }
            }

            strResult = handler.Json.ClassToJson(ht);

            return strResult;
        }
    }

    //所有发货授权车辆
    public class A04 : IMobileChild
    {
        public string Code(IMobile handler, ClientUser user, string parameter)
        {
            string strResult = "";
            int nCount = 1;
            int nTotalPages = 0;
            // Dictionary<string, AuthCarInfor> ht = new Dictionary<string, AuthCarInfor>();
            List<AuthCarInfor> ht = new List<AuthCarInfor>();
            FunctionParameter fp = new FunctionParameter();

            fp = (FunctionParameter)handler.Json.JsonToClass(parameter, typeof(FunctionParameter));

            SqlParameter[] sps = new SqlParameter[1];
            sps[0] = new SqlParameter("@FID", SqlDbType.NChar, 50);
            sps[0].Value = fp.OrderFID;

            string strSQL = "select A.FID 车辆FID,A.FBillNo 过磅编号, A.FText12 发货授权编号,C.FName 产品,C.FID 产品FID,C.FCheckBox 是否袋装,A.FDecimal4 计划预装,A.FText 车牌号码 from KEW_SalesInfo A ";
            strSQL = strSQL + "left join t_Organization B on B.FItemID=A.FBase1 ";
            //strSQL = strSQL + "left join KEW_Products C on C.FID=A.FBase ";
            strSQL = strSQL + "left join KEW_ProductsEntry C on C.FID=A.FBase ";
            strSQL = strSQL + "left join KEW_SalesCar D on D.FID=A.FBase3 ";
            strSQL = strSQL + "left join KEW_SalesInfoEntry E on E.FID=A.FID ";
            strSQL = strSQL + "left join KEW_SaleOrderQty F on F.FID=E.FID_SRC ";
            strSQL = strSQL + "where F.FID=@FID and A.FComboBox='-1' and A.FCheckBox4='0' order by A.FID desc";

            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                strResult = "";
                return strResult;
            }

            if (rs.Data.Tables[0].Rows.Count % fp.PageSize == 0)
            {
                nTotalPages = rs.Data.Tables[0].Rows.Count / fp.PageSize;
            }
            else
            {
                nTotalPages = rs.Data.Tables[0].Rows.Count / fp.PageSize + 1;
            }

            foreach (DataTable dt in rs.Data.Tables)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    if ((fp.PageSize * fp.Page >= nCount) && ((fp.Page - 1) * fp.PageSize < nCount))
                    {
                        AuthCarInfor authCar = new AuthCarInfor();

                        authCar.FID = dr["车辆FID"].ToString();
                        authCar.OrderFID = fp.OrderFID;
                        authCar.WeighNumber = dr["过磅编号"].ToString();
                        authCar.PreviousPlan = Math.Round(Common.CDec(dr["计划预装"].ToString()), Common.QtyPrecision).ToString();
                        authCar.AuthNumber = dr["发货授权编号"].ToString();
                        authCar.CarNumber = dr["车牌号码"].ToString();
                        authCar.ProductName = dr["产品"].ToString();
                        authCar.ProductFID = dr["产品FID"].ToString();
                        authCar.IsBag = dr["是否袋装"].ToString();
                        authCar.TotalPages = nTotalPages;
                        ht.Add(authCar);
                    }

                    if (nCount == fp.PageSize * fp.Page)
                    {
                        break;
                    }
                    nCount++;
                }
            }

            strResult = handler.Json.ClassToJson(ht);

            return strResult;
        }
    }

    //作废发货授权单
    public class A06 : IMobileChild
    {

        public string Code(IMobile handler, ClientUser user, string parameter)
        {
            string strResult = "";

            FunctionParameter fp = new FunctionParameter();

            fp = (FunctionParameter)handler.Json.JsonToClass(parameter, typeof(FunctionParameter));

            SqlParameter[] sps = new SqlParameter[1];
            sps[0] = new SqlParameter("@FID", SqlDbType.NChar, 50);
            sps[0].Value = fp.AuthCarFID;

            string strSQL = "Exec KEW_SALESAUTH_CANCEL @FID";

            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                strResult = "";
                return strResult;
            }

            strResult = rs.Data.Tables[0].Rows[0][0].ToString();

            return strResult;
        }

    }

    //补录发货授权单（选多个订单）
    public class A09 : IMobileChild
    {
        /// <summary>
        /// 生成4位数字随机数。
        /// </summary>
        /// <returns>生成的随机数</returns>
        //private string random_6()
        //{
        //    Random rad = new Random();//实例化随机数产生器rad；
        //    string strRandom = "";
        //    strRandom = Convert.ToString(rad.Next(111000, 999999));

        //    return strRandom;
        //}
        private int GetRandom(IMobile handler, String accountid)
        {
            Random rd = new Random();
            int random = rd.Next(1000000, 10000000);

            int nResult = 0;
            SqlParameter[] sps = new SqlParameter[1];
            sps[0] = new SqlParameter("@Random", SqlDbType.Int);
            sps[0].Value = random;

            String AuthCar = accountid + random.ToString();
            string strSql = " select * from KEW_SalesInfo where FText14='" + AuthCar.Trim() + "' and FComboBox = '-1' ";

            Recordset rs = handler.Data.ExeProcedure(accountid, strSql, sps);
            nResult = rs.Data.Tables[0].Rows.Count;

            //查数据
            if (nResult > 0)
            {
                GetRandom(handler, accountid);
            }
            return random;

        }

        public List<OrderPro> Sort(List<OrderPro> listorderPro)
        {
            OrderPro temp = new OrderPro();
            for (int i = 0; i < listorderPro.Count; i++)
            {
                for (int j = i; j < listorderPro.Count; j++)
                {
                    if (Common.CDec(listorderPro[i].Allowance) >= Common.CDec(listorderPro[j].Allowance))
                    {
                        temp = listorderPro[i];
                        listorderPro[i] = listorderPro[j];
                        listorderPro[j] = temp;
                    }
                }
            }

            return listorderPro;
        }

        #region 获取当天某订单下发货授权车数
        /// <summary>
        /// 获取当天某订单下发货授权车数
        /// </summary>
        /// <param name="strFID">销售订单的FID</param>
        /// <param name="strConnection">连接字符串</param>
        /// <returns></returns>
        private int GetAuthCarCountNow(string strFID, IMobile handler, ClientUser user)
        {
            int nResult = 0;
            SqlParameter[] sps = new SqlParameter[1];
            sps[0] = new SqlParameter("@FID", SqlDbType.NChar, 50);
            sps[0].Value = strFID;

            string strSQL = "select * from KEW_SalesInfo A ";
            strSQL = strSQL + "left join KEW_SalesInfoEntry B on B.FID=A.FID ";
            strSQL = strSQL + "left join KEW_SaleOrderQty C on C.FID=B.FID_SRC ";
            strSQL = strSQL + "where C.FID=@FID and A.FComboBox='-1' and A.FCheckBox4='0' and A.FTime>='" + DateTime.Now.ToString("yyyy-MM-dd") + "' and A.FTime<='" + DateTime.Now.ToString() + "'";

            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);
            nResult = rs.Data.Tables[0].Rows.Count;

            return nResult;
        }
        #endregion

        #region 获取当天占用吨数
        public decimal GetSalesDayQty(IMobile handler, ClientUser user)
        {
            decimal dResult = 0;
            SqlParameter[] sps = new SqlParameter[1];
            sps[0] = new SqlParameter("@FID", SqlDbType.NChar, 50);
            sps[0].Value = user.UserName;

            string strSQL = "select sum(B.FDecimal9) from KEW_SalesInfo A ";
            strSQL = strSQL + "left join KEW_SalesInfoEntry B on B.FID=A.FID ";
            strSQL = strSQL + "left join KEW_SaleOrderQty C on C.FID=B.FID_SRC ";
            strSQL = strSQL + "left join KEW_SalesGuests D on D.FID=C.FID_SRC ";
            strSQL = strSQL + "where D.FBillNo=@FID and A.FCheckBox4='0' and A.FTime>='" + DateTime.Now.ToString("yyyy-MM-dd") + "' and A.FTime<='" + DateTime.Now.ToString() + "'";

            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                return 0;
            }

            dResult = Common.CDec(rs.Data.Tables[0].Rows[0][0].ToString());

            return dResult;
        }
        #endregion

        #region 获取客户每天上线吨位
        public decimal GetSalesDayLimitQty(IMobile handler, ClientUser user)
        {
            decimal dResult = 0;
            SqlParameter[] sps = new SqlParameter[1];
            sps[0] = new SqlParameter("@FID", SqlDbType.NChar, 50);
            sps[0].Value = user.UserName;

            string strSQL = "select top 1 A.FDecimal from KEW_SalesLimit A ";
            strSQL = strSQL + "left join KEW_SalesGuests B on B.FID=A.FID_SRC ";
            strSQL = strSQL + "where B.FBillNo=@FID and A.FCheckBox=1 ";

            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                return 0;
            }

            dResult = Common.CDec(rs.Data.Tables[0].Rows[0][0].ToString());

            return dResult;
        }
        #endregion

        public string Code(IMobile handler, ClientUser user, string parameter)
        {
            string strResult = "";
            FunctionParameter fp = new FunctionParameter();
            List<OrderPro> op = new List<OrderPro>();
            AuthCarInfor sc = new AuthCarInfor();
            AuthResult authResult = new AuthResult();
            List<AuthResult> ht = new List<AuthResult>();

            fp = (FunctionParameter)handler.Json.JsonToClass(parameter, typeof(FunctionParameter));
            sc = (AuthCarInfor)handler.Json.JsonToClass(fp.SalesAuthCarInfo, typeof(AuthCarInfor));

            if (GetSalesDayLimitQty(handler, user) != 0)
            {
                if (GetSalesDayLimitQty(handler, user) < GetSalesDayQty(handler, user))
                {
                    authResult.IsSuccess = "FALSE";
                    authResult.AuthFID = "超出每天限制吨数！";

                    ht.Add(authResult);
                    strResult = handler.Json.ClassToJson(ht);
                    return strResult;
                }
            }

            if (!sc.listOrderPro.Equals("[]"))
            {
                op = (List<OrderPro>)handler.Json.JsonToClass(sc.listOrderPro, typeof(List<OrderPro>));
                op = Sort(op);
            }

            SqlParameter[] sps = new SqlParameter[5 + op.Count * 2];
            sps[0] = new SqlParameter("@SaleOrderQtyFID", SqlDbType.NChar, 50);
            sps[0].Value = sc.OrderFID;
            sps[1] = new SqlParameter("@CarNo", SqlDbType.NChar, 50);
            sps[1].Value = sc.CarNumber;
            sps[2] = new SqlParameter("@PreQTY", SqlDbType.NChar, 50);
            sps[2].Value = sc.PreviousPlan;
            sps[3] = new SqlParameter("@Stamp", SqlDbType.NChar, 50);
            sps[3].Value = sc.TakePass;
            sps[4] = new SqlParameter("@AuthCar", SqlDbType.NVarChar, 50);
            //sps[4].Value = user.AccountID + random_6();
            sps[4].Value = user.AccountID + GetRandom(handler, user.AccountID);

            for (int i = 0; i < op.Count; i++)
            {
                sps[5 + 2 * i] = new SqlParameter("@OrderFID" + i.ToString(), SqlDbType.NChar, 50);
                sps[5 + 2 * i].Value = op[i].OrderFID;
                sps[6 + 2 * i] = new SqlParameter("@TakePass" + i.ToString(), SqlDbType.NChar, 50);
                sps[6 + 2 * i].Value = op[i].TakePass;
            }

            string strSQL = "SET NOCOUNT ON ";
            strSQL = strSQL + "SET NOCOUNT ON ";
            strSQL = strSQL + "DECLARE @FID INT ";
            strSQL = strSQL + "DECLARE @BillNo NVARCHAR(50) ";
            strSQL = strSQL + "DECLARE @Now DATETIME ";
            strSQL = strSQL + "DECLARE @BalQTY DECIMAL(23,10) ";
            strSQL = strSQL + "DECLARE @BalAmt DECIMAL(23,10) ";
            strSQL = strSQL + "DECLARE @TaxRate DECIMAL(23,10) ";
            strSQL = strSQL + "DECLARE @OrderNo NVARCHAR(50) ";
            strSQL = strSQL + "DECLARE @OrderID INT ";
            strSQL = strSQL + "DECLARE @OrderPrice DECIMAL(23,10) ";
            strSQL = strSQL + "DECLARE @OrderTypeID INT ";
            strSQL = strSQL + "DECLARE @OrderQty DECIMAL(23,10) ";
            strSQL = strSQL + "DECLARE @ControlMode NVARCHAR(50) ";
            strSQL = strSQL + "DECLARE @GustID INT ";
            strSQL = strSQL + "DECLARE @Department INT ";
            strSQL = strSQL + "DECLARE @Staff INT ";
            strSQL = strSQL + "DECLARE @ItemID INT ";
            strSQL = strSQL + "DECLARE @UnitID INT ";
            strSQL = strSQL + "DECLARE @ReplenisFirstPreQTY DECIMAL(23,10) ";
            strSQL = strSQL + "DECLARE @ErrorCount AS INT ";
            strSQL = strSQL + "SET @ErrorCount=0 ";

            strSQL = strSQL + "IF (SELECT COUNT(1) FROM KEW_SalesInfo WHERE FText5=@Stamp)>0 BEGIN ";
            strSQL = strSQL + "SELECT 'FALSE','不能重复插入！' ";
            strSQL = strSQL + "RETURN ";
            strSQL = strSQL + "END ";
            strSQL = strSQL + "EXEC KEW_GET_BillNo 236900103,1,@BillNo OUTPUT ";
            strSQL = strSQL + "IF @BillNo='' BEGIN ";
            strSQL = strSQL + "SELECT 'FALSE','新增销售过磅信息时获取单据编号出错！' ";
            strSQL = strSQL + "RETURN ";
            strSQL = strSQL + "END ";
            //base6业务员 base7部门
            strSQL = strSQL + "EXEC GetICMaxNum 'KEW_SalesInfo',@FID OUTPUT ";
            //strSQL = strSQL + "set @AuthCar=left(@AuthCar,1)+@BillNo+RIGHT(@AuthCar,6) ";
            strSQL = strSQL + "SET @Now=GETDATE() ";
            strSQL = strSQL + "SELECT @TaxRate=FDecimal2, @BalQTY=FDecimal11,@BalAmt=FDecimal9-FDecimal12,@ItemID=FBase4,@UnitID=FBase2,@Department=FBase7,@Staff=FBase6,@GustID=FBase,@OrderNo=FBillNo,@OrderID=FID,@OrderTypeID=FClassTypeID,@ControlMode=FComboBox,@OrderQty=FDecimal, ";
            strSQL = strSQL + "@OrderPrice=FDecimal3+FDecimal7+FDecimal13 ";
            strSQL = strSQL + "FROM KEW_SaleOrderQty ";
            strSQL = strSQL + "WHERE FID=@SaleOrderQtyFID ";
            strSQL = strSQL + "BEGIN TRAN ";
            strSQL = strSQL + "INSERT INTO KEW_SalesInfo ([FID],[FClassTypeID],[FBillNo],[FAmount],[FAmount1],[FAmount2],[FComboBox],[FText],[FDecimal] ";
            strSQL = strSQL + ",[FDecimal1],[FDecimal2],[FDecimal3],[FDecimal4],[FTime],[FTime1],[FTime2],[FText1],[FText2],[FText3],[FBase],[FNOTE] ";
            strSQL = strSQL + ",[FCheckBox],[FBase1],[FBase2],[FText4],[FText8],[FText5],[FNOTE2],[FCheckBox4],[FComboBox2],[FText14],[FBase7],[FComboBox3]) VALUES ";
            strSQL = strSQL + "(@FID,236900103,@BillNo,0.00,0.00,0.00,'-1',@CarNo,0.00 ";
            strSQL = strSQL + ",0,0,0,@PreQty,@Now,Null,Null,'','','',@ItemID,'' ";
            strSQL = strSQL + ",0,@GustID,@UnitID,'','',@Stamp,'',0,'0',@AuthCar,@Department,4) ";
            strSQL = strSQL + "SET @ErrorCount=@ErrorCount+@@ERROR ";
            //部门bAse7 业务员 Base8
            if (op.Count == 0)
            {
                strSQL = strSQL + "if @BalQTY>=@PreQTY begin ";
                strSQL = strSQL + "set @ReplenisFirstPreQTY=@PreQTY set  @PreQTY=0 end ";
                strSQL = strSQL + "else begin ";
                strSQL = strSQL + "set @ReplenisFirstPreQTY=@BalQTY ";
                strSQL = strSQL + "set @PreQTY=@PreQTY-@ReplenisFirstPreQTY ";
                strSQL = strSQL + "end ";
                strSQL = strSQL + "INSERT INTO KEW_SalesInfoEntry ([FID],[FIndex],[FBillNo_SRC],[FClassID_SRC],[FComboBox1],[FDecimal11],[FDecimal5] ";
                strSQL = strSQL + ",[FDecimal6],[FDecimal7],[FDecimal8],[FDecimal9],[FDecimal10],[FID_SRC],[FEntryID_SRC],[FCheckBox2],[FBase4] ";
                strSQL = strSQL + ",[FText6],[FText7],[FInteger],[FDecimal15],[FDecimal18],[FBase6],[FBase9]) VALUES ";
                strSQL = strSQL + "(@FID,1,@OrderNo,@OrderTypeID,@ControlMode,@OrderQty,@BalQTY ";
                strSQL = strSQL + ",@BalAmt,@OrderPrice,@TaxRate,@ReplenisFirstPreQTY,ROUND(@ReplenisFirstPreQTY*@OrderPrice,2),@OrderID,0,0,@GustID ";
                strSQL = strSQL + ",@Stamp,'',0,@OrderPrice,@BalQTY-@ReplenisFirstPreQTY,@Department,@Staff) ";
                strSQL = strSQL + "SET @ErrorCount=@ErrorCount+@@ERROR ";
            }

            for (int i = 0; i < op.Count; i++)
            {
                strSQL = strSQL + "SELECT @TaxRate=FDecimal2,@BalQTY=FDecimal11,@BalAmt=FDecimal9-FDecimal12,@ItemID=FBase4,@UnitID=FBase2,@GustID=FBase,@Department=FBase7,@Staff=FBase6,@OrderNo=FBillNo,@OrderID=FID,@OrderTypeID=FClassTypeID,@ControlMode=FComboBox,@OrderQty=FDecimal, ";
                strSQL = strSQL + "@OrderPrice=FDecimal3+FDecimal7+FDecimal13 ";
                strSQL = strSQL + "FROM KEW_SaleOrderQty ";
                strSQL = strSQL + "WHERE FID=@OrderFID" + i.ToString() + " ";
                strSQL = strSQL + "if @BalQTY>=@PreQTY begin ";
                strSQL = strSQL + "set @ReplenisFirstPreQTY=@PreQTY end ";
                strSQL = strSQL + "else begin ";
                strSQL = strSQL + "set @ReplenisFirstPreQTY=@BalQTY ";
                strSQL = strSQL + "set @PreQTY=@PreQTY-@ReplenisFirstPreQTY ";
                strSQL = strSQL + "end ";

                strSQL = strSQL + "INSERT INTO KEW_SalesInfoEntry ([FID],[FIndex],[FBillNo_SRC],[FClassID_SRC],[FComboBox1],[FDecimal11],[FDecimal5] ";
                strSQL = strSQL + ",[FDecimal6],[FDecimal7],[FDecimal8],[FDecimal9],[FDecimal10],[FID_SRC],[FEntryID_SRC],[FCheckBox2],[FBase4] ";
                strSQL = strSQL + ",[FText6],[FText7],[FInteger],[FDecimal15],[FDecimal18],[FBase6],[FBase9]) VALUES ";
                strSQL = strSQL + "(@FID,1,@OrderNo,@OrderTypeID,@ControlMode,@OrderQty,@BalQTY ";
                strSQL = strSQL + ",@BalAmt,@OrderPrice,@TaxRate,@ReplenisFirstPreQTY,ROUND(@ReplenisFirstPreQTY*@OrderPrice,2),@OrderID,0,0,@GustID ";
                strSQL = strSQL + ",@TakePass" + i.ToString() + ",'',0,@OrderPrice,@BalQTY-@ReplenisFirstPreQTY,@Department,@Staff) ";
                strSQL = strSQL + "if (SELECT COUNT(1) FROM KEW_SalesInfoEntry WHERE FText6=@TakePass" + i.ToString() + " AND FID=@FID)<>1 BEGIN ";
                strSQL = strSQL + "SET @ErrorCount=-1 ";
                strSQL = strSQL + "END ";
                strSQL = strSQL + "SET @ErrorCount=@ErrorCount+@@ERROR ";
            }

            strSQL = strSQL + "IF @ErrorCount=0 AND (SELECT COUNT(1) FROM KEW_SalesInfo WHERE FText5=@Stamp AND FID=@FID)=1 ";
            strSQL = strSQL + "BEGIN ";
            //strSQL = strSQL + "SELECT 'TRUE',@Now,@FID,@BillNo ";
            strSQL = strSQL + "SELECT 'TRUE',@FID ";
            strSQL = strSQL + "COMMIT TRAN ";
            strSQL = strSQL + "END ";
            strSQL = strSQL + "ELSE BEGIN ";
            strSQL = strSQL + "SELECT 'FALSE','事务出错回滚' ";
            strSQL = strSQL + "ROLLBACK TRAN ";
            strSQL = strSQL + "END ";
            strSQL = strSQL + "SET NOCOUNT OFF";

            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                strResult = "";
                return strResult;
            }

            //strResult = rs.Data.Tables[0].Rows[0][0].ToString(); ;
            //return strResult;

            authResult.IsSuccess = rs.Data.Tables[0].Rows[0][0].ToString();
            authResult.AuthFID = rs.Data.Tables[0].Rows[0][1].ToString();

            ht.Add(authResult);
            strResult = handler.Json.ClassToJson(ht);
            return strResult;
        }
    }

    //单一车辆详情
    public class A10 : IMobileChild
    {
        public string Code(IMobile handler, ClientUser user, string parameter)
        {
            string strResult = "";
            string strQuery = "";
            string strNewFID = "";
            SalesCarInfor orderInfor = new SalesCarInfor();
            //Dictionary<string, SalesCarInfor> ht = new Dictionary<string, SalesCarInfor>();
            List<SalesCarInfor> ht = new List<SalesCarInfor>();

            FunctionParameter fp = new FunctionParameter();

            fp = (FunctionParameter)handler.Json.JsonToClass(parameter, typeof(FunctionParameter));

            SqlParameter[] sps = new SqlParameter[1];
            sps[0] = new SqlParameter("@FID", SqlDbType.NChar, 50);
            sps[0].Value = fp.OrderFID;

            string strSQL = "select A.FID 车辆FID,A.FBillNo 过磅编号,A.FText 车牌号码,A.FDecimal4 计划预装,A.FDecimal 进厂重量,A.FDecimal1 出厂重量,A.FDecimal2 实际净重,A.FDecimal3 出库数量,A.FComboBox 称量状态,A.FComboBox2 过磅类型,A.FTime 开票时间,A.FTime1 进厂时间,A.FTime2 出厂时间,A.FText8 磁卡,A.FText12 发货授权编号,B.FName 客户,C.FName 产品,A.FText1 开票人员,A.FText2 进厂司磅,A.FText3 出厂司磅,A.FDecimal19 盈亏,A.FText9 签发人员,D.FName 销售车辆,A.FComboBox3 生产线, A.FCheckBox4 作废标志,E.FDecimal7 产品单价,E.FDecimal9 扣除数量,E.FDecimal6 剩余金额,E.FDecimal10 扣除金额,E.FBillNo_SRC 订单编号 from KEW_SalesInfo A ";
            strSQL = strSQL + "left join t_Organization B on B.FItemID=A.FBase1 ";
            strSQL = strSQL + "left join KEW_Products C on C.FID=A.FBase ";
            strSQL = strSQL + "left join KEW_SalesCar D on D.FID=A.FBase3 ";
            strSQL = strSQL + "left join KEW_SalesInfoEntry E on E.FID=A.FID ";
            strSQL = strSQL + "left join KEW_SaleOrderQty F on F.FID=E.FID_SRC ";
            strSQL = strSQL + "left join KEW_SalesGuests G on G.FID=F.FID_SRC ";
            strSQL = strSQL + "where A.FID=@FID";

            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                strResult = "";
                return strResult;
            }

            foreach (DataTable dt in rs.Data.Tables)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    ProductOrder productInfor = new ProductOrder();

                    if (!strNewFID.Equals(dr[0].ToString()))
                    {
                        orderInfor.FID = dr[0].ToString();
                        orderInfor.WeighNumber = dr[1].ToString();
                        orderInfor.CarNumber = dr[2].ToString();
                        orderInfor.PreviousPlan = Math.Round(Common.CDec(dr[3].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.InWeight = Math.Round(Common.CDec(dr[4].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.OutWeight = Math.Round(Common.CDec(dr[5].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.FactNetWeight = Math.Round(Common.CDec(dr[6].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.OutStorage = Math.Round(Common.CDec(dr[7].ToString()), Common.QtyPrecision).ToString();

                        strQuery = dr[8].ToString().Trim();
                        if (Common.CInt(strQuery) == 0)
                        {
                            orderInfor.WeighStatues = "开票";
                        }
                        else if (Common.CInt(strQuery) == 1)
                        {
                            orderInfor.WeighStatues = "已开票";
                        }
                        else if (Common.CInt(strQuery) == 2)
                        {
                            orderInfor.WeighStatues = "已进厂计量";
                        }
                        else if (Common.CInt(strQuery) == 3)
                        {
                            orderInfor.WeighStatues = "计量完成";
                        }
                        else if (Common.CInt(strQuery) == -1)
                        {
                            orderInfor.WeighStatues = "已发货授权";
                        }

                        strQuery = dr[24].ToString().Trim();
                        if (Common.CBool(strQuery))
                        {
                            orderInfor.WeighStatues = "已作废";
                        }

                        strQuery = dr[9].ToString().Trim();
                        if (Common.CInt(strQuery) == 0)
                        {
                            orderInfor.WeighType = "正常过磅";
                        }
                        else if (Common.CInt(strQuery) == 1)
                        {
                            orderInfor.WeighType = "退货";
                        }
                        else if (Common.CInt(strQuery) == 2)
                        {
                            orderInfor.WeighType = "空车出厂";
                        }

                        orderInfor.TicketTime = dr[10].ToString();
                        orderInfor.InTime = dr[11].ToString();
                        orderInfor.OutTime = dr[12].ToString();
                        orderInfor.CardNum = dr[13].ToString();
                        orderInfor.OrderNumber = dr[14].ToString();
                        orderInfor.ClientName = dr[15].ToString();
                        orderInfor.ProductName = dr[16].ToString();
                        orderInfor.BillingMan = dr[17].ToString();
                        orderInfor.InSiBang = dr[18].ToString();
                        orderInfor.OutSiBang = dr[19].ToString();
                        orderInfor.ProfitAndLoss = Math.Round(Common.CDec(dr[20].ToString()), Common.PricePrecision).ToString();
                        orderInfor.SignMan = dr[21].ToString();
                        orderInfor.SalesCar = dr[22].ToString();
                        orderInfor.ProduceNumber = dr[23].ToString();
                        strNewFID = orderInfor.FID;
                    }

                    //,E.FDecimal7 产品单价,E.FDecimal6 剩余金额,E.FDecimal10 扣除金额,E.FBillNo_SRC 订单编号
                    productInfor.Price = Math.Round(Common.CDec(dr["产品单价"].ToString()), Common.PricePrecision).ToString();
                    productInfor.SurplusMoney = Math.Round(Common.CDec(dr["剩余金额"].ToString()), Common.PricePrecision).ToString();
                    productInfor.DeductNumber = Math.Round(Common.CDec(dr["扣除数量"].ToString()), Common.QtyPrecision).ToString();
                    productInfor.ConsumeMoney = Math.Round(Common.CDec(dr["扣除金额"].ToString()), Common.PricePrecision).ToString();
                    productInfor.OrderBillno = dr["订单编号"].ToString();
                    orderInfor.listProductOrderInfor.Add(productInfor);
                }
            }

            ht.Add(orderInfor);
            strResult = handler.Json.ClassToJson(ht);

            return strResult;
        }
    }

    //单一发货授权详情
    public class A11 : IMobileChild
    {
        public string Code(IMobile handler, ClientUser user, string parameter)
        {
            string strResult = "";
            string strNewFID = "";
            //Dictionary<string, AuthCarInfor> ht = new Dictionary<string, AuthCarInfor>();
            List<AuthCarInfor> ht = new List<AuthCarInfor>();
            List<ProductOrder> listProductOrderInfor = new List<ProductOrder>();

            FunctionParameter fp = new FunctionParameter();
            AuthCarInfor authCar = new AuthCarInfor();

            fp = (FunctionParameter)handler.Json.JsonToClass(parameter, typeof(FunctionParameter));

            SqlParameter[] sps = new SqlParameter[1];
            sps[0] = new SqlParameter("@FID", SqlDbType.NChar, 50);
            sps[0].Value = fp.AuthCarFID;

            string strSQL = "select A.FID 车辆FID,A.FBillNo 过磅编号,A.FText 车牌号码,A.FDecimal4 计划预装,A.FText14 发货授权编号,C.FName 产品,C.FID 产品FID,C.FCheckBox 是否袋装,E.FDecimal7 产品单价,E.FDecimal9 扣除数量,E.FDecimal5 剩余数量,E.FDecimal10 扣除金额,E.FBillNo_SRC 订单编号,F.FID 订单FID,B.FName 客户 from KEW_SalesInfo A ";
            strSQL = strSQL + "left join t_Organization B on B.FItemID=A.FBase1 ";
            //strSQL = strSQL + "left join KEW_Products C on C.FID=A.FBase ";
            strSQL = strSQL + "left join KEW_ProductsEntry C on C.FID=A.FBase ";
            strSQL = strSQL + "left join KEW_SalesCar D on D.FID=A.FBase3 ";
            strSQL = strSQL + "left join KEW_SalesInfoEntry E on E.FID=A.FID ";
            strSQL = strSQL + "left join KEW_SaleOrderQty F on F.FID=E.FID_SRC ";
            strSQL = strSQL + "where A.FID=@FID and A.FComboBox='-1' and A.FCheckBox4='0' order by A.FID desc";

            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                strResult = "";
                return strResult;
            }

            foreach (DataTable dt in rs.Data.Tables)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    ProductOrder productInfor = new ProductOrder();

                    if (!strNewFID.Equals(dr[0].ToString()))
                    {
                        authCar.FID = dr["车辆FID"].ToString();
                        authCar.OrderFID = dr["订单FID"].ToString();
                        authCar.WeighNumber = dr["过磅编号"].ToString();
                        authCar.PreviousPlan = Math.Round(Common.CDec(dr["计划预装"].ToString()), Common.QtyPrecision).ToString();
                        authCar.AuthNumber = dr["发货授权编号"].ToString();
                        authCar.CarNumber = dr["车牌号码"].ToString();
                        authCar.ProductName = dr["产品"].ToString();
                        authCar.ProductFID = dr["产品FID"].ToString();
                        authCar.IsBag = dr["是否袋装"].ToString();
                        authCar.OrgName = dr["客户"].ToString();
                        strNewFID = authCar.FID;
                    }

                    productInfor.Price = Math.Round(Common.CDec(dr["产品单价"].ToString()), Common.PricePrecision).ToString();
                    productInfor.DeductNumber = Math.Round(Common.CDec(dr["扣除数量"].ToString()), Common.QtyPrecision).ToString();
                    productInfor.SurplusMoney = Math.Round(Common.CDec(dr["剩余数量"].ToString()), Common.QtyPrecision).ToString();
                    productInfor.ConsumeMoney = Math.Round(Common.CDec(dr["扣除金额"].ToString()), Common.PricePrecision).ToString();
                    productInfor.OrderBillno = dr["订单编号"].ToString();
                    listProductOrderInfor.Add(productInfor);
                }
            }

            authCar.listOrderPro = handler.Json.ClassToJson(listProductOrderInfor);
            ht.Add(authCar);
            strResult = handler.Json.ClassToJson(ht);

            return strResult;
        }
    }

    //筛选订单信息
    public class A12 : IMobileChild
    {
        public string Code(IMobile handler, ClientUser user, String parameter)
        {
            string strResult = "";
            int nCount = 1;
            int nTotalPages = 0;
            string strProFID = "";
            // Dictionary<string, SalesOrderInfor> ht = new Dictionary<string, SalesOrderInfor>();
            List<SalesOrderInfor> ht = new List<SalesOrderInfor>();
            List<string> listop = new List<string>();

            FunctionParameter fp = new FunctionParameter();

            fp = (FunctionParameter)handler.Json.JsonToClass(parameter, typeof(FunctionParameter));

            if (!fp.listOrderFID.Equals("[]") && !fp.listOrderFID.Equals(""))
            {
                listop = (List<string>)handler.Json.JsonToClass(fp.listOrderFID, typeof(List<string>));
            }
            if (!fp.ProductFID.Equals(""))
            {
                strProFID = fp.ProductFID;
            }

            SqlParameter[] sps = new SqlParameter[2 + listop.Count];
            sps[0] = new SqlParameter("@FBillNo", SqlDbType.NChar, 50);
            sps[0].Value = user.UserName;
            for (int i = 0; i < listop.Count; i++)
            {
                sps[1 + i] = new SqlParameter("@FID" + i.ToString(), SqlDbType.NChar, 50);
                sps[1 + i].Value = listop[i];
            }
            sps[1 + listop.Count] = new SqlParameter("@ProFID", SqlDbType.NChar, 50);
            sps[1 + listop.Count].Value = strProFID;

            string strSQL = "select A.FID 订单FID,A.FBillNo 订单编号,D.FName 客户,B.FName 产品,A.FDecimal 数量,A.FDecimal3 含税单价,A.FDecimal7 含税运价,A.FDecimal8 运输金额,A.FDecimal4 含税金额,A.FDecimal9 总金额,A.FDate 下单日期,A.FDecimal10 已用数量,A.FDecimal12 已用金额,A.FDecimal5 运输单价,A.FDecimal6 运费税率,A.FDecimal1 单价,A.FDecimal2 税率,F.FName 袋装标准,G.FName 计量方案,A.FDecimal11 余量,C.FName 业务员,A.FDecimal13 其它单价,A.FDecimal14 其它金额,H.FName 销售方式,E.FName 结算方式 from KEW_SaleOrderQty A ";
            strSQL = strSQL + "left join KEW_Products B on B.FID=A.FBase4 ";
            strSQL = strSQL + "left join t_Emp C on C.FItemID=A.FBase6 ";
            strSQL = strSQL + "left join t_Organization D on D.FItemID=A.FBase ";
            strSQL = strSQL + "left join t_Settle E on E.FItemID=A.FBase8 ";
            strSQL = strSQL + "left join KEW_ProductsBagRule F on F.FParentID=A.FBase3 ";
            strSQL = strSQL + "left join KEW_SalesConfig G on G.FID=A.FBase5 ";
            strSQL = strSQL + "left join t_SubMessage H on H.FInterID=A.FComboBox1 ";
            strSQL = strSQL + "left join KEW_SalesGuests I on I.FID=A.FID_SRC ";
            strSQL = strSQL + "where I.FBillNo=@FBillNo and ";

            for (int i = 0; i < listop.Count; i++)
            {
                strSQL = strSQL + "A.FID<>@FID" + i.ToString() + " and ";
            }
            if (!strProFID.Equals(""))
            {
                strSQL = strSQL + " A.FBase4 = @ProFID and ";
            }
            strSQL = strSQL + "A.FMultiCheckStatus='16' and A.FDecimal11>0 and A.FCheckBox=0 order by A.FID desc";


            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                strResult = "";
                return strResult;
            }

            if (rs.Data.Tables[0].Rows.Count % fp.PageSize == 0)
            {
                nTotalPages = rs.Data.Tables[0].Rows.Count / fp.PageSize;
            }
            else
            {
                nTotalPages = rs.Data.Tables[0].Rows.Count / fp.PageSize + 1;
            }

            foreach (DataTable dt in rs.Data.Tables)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    if ((fp.PageSize * fp.Page >= nCount) && ((fp.Page - 1) * fp.PageSize < nCount))
                    {
                        SalesOrderInfor orderInfor = new SalesOrderInfor();
                        orderInfor.FID = dr[0].ToString();
                        orderInfor.FBillNo = dr[1].ToString();
                        orderInfor.ClientName = dr[2].ToString();
                        orderInfor.ProductName = dr[3].ToString();
                        orderInfor.Amount = Math.Round(Common.CDec(dr[4].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.TaxPrice = Math.Round(Common.CDec(dr[5].ToString()), Common.PricePrecision).ToString();
                        orderInfor.TaxTransatePrice = Math.Round(Common.CDec(dr[6].ToString()), Common.PricePrecision).ToString();
                        orderInfor.TransateMoney = Math.Round(Common.CDec(dr[7].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.TaxMoney = Math.Round(Common.CDec(dr[8].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.TotalMoney = Math.Round(Common.CDec(dr[9].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.OrderDate = dr[10].ToString();
                        orderInfor.UsedNumber = Math.Round(Common.CDec(dr[11].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.UsedMoney = Math.Round(Common.CDec(dr[12].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.TransatePrice = Math.Round(Common.CDec(dr[13].ToString()), Common.PricePrecision).ToString();
                        orderInfor.TaxTransateRate = Math.Round(Common.CDec(dr[14].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.Price = Math.Round(Common.CDec(dr[15].ToString()), Common.PricePrecision).ToString();
                        orderInfor.TaxRate = Math.Round(Common.CDec(dr[16].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.BagStandard = dr[17].ToString();
                        orderInfor.MeasurementPlan = dr[18].ToString();
                        orderInfor.Allowance = Math.Round(Common.CDec(dr[19].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.SalesMan = dr[20].ToString();
                        orderInfor.OtherPrice = Math.Round(Common.CDec(dr[21].ToString()), Common.PricePrecision).ToString();
                        orderInfor.OtherMoney = Math.Round(Common.CDec(dr[22].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.SalesWay = dr[23].ToString();
                        orderInfor.SettleWay = dr[24].ToString();
                        orderInfor.TotalPages = nTotalPages;
                        ht.Add(orderInfor);

                    }

                    if (nCount == fp.PageSize * fp.Page)
                    {
                        break;
                    }
                    nCount++;
                }
            }

            strResult = handler.Json.ClassToJson(ht);
            return strResult;
        }
    }

    //所有销售车辆
    public class A13 : IMobileChild
    {
        public string Code(IMobile handler, ClientUser user, string parameter)
        {
            string strResult = "";
            int nCount = 1;
            int nTotalPages = 0;
            string strQuery = "";
            // Dictionary<string, SalesCarInfor> ht = new Dictionary<string, SalesCarInfor>();
            List<SalesCarInfor> ht = new List<SalesCarInfor>();
            FunctionParameter fp = new FunctionParameter();

            fp = (FunctionParameter)handler.Json.JsonToClass(parameter, typeof(FunctionParameter));

            SqlParameter[] sps = new SqlParameter[4];
            sps[0] = new SqlParameter("@FID", SqlDbType.NChar, 50);
            sps[0].Value = fp.OrderFID;
            sps[1] = new SqlParameter("@FBillNo", SqlDbType.NChar, 50);
            sps[1].Value = user.UserName;
            sps[2] = new SqlParameter("@StartTime", SqlDbType.NChar, 50);
            sps[2].Value = fp.StartTime;
            sps[3] = new SqlParameter("@EndTime", SqlDbType.NChar, 50);
            sps[3].Value = fp.EndTime;
            sps[4] = new SqlParameter("@Statues", SqlDbType.NChar, 50);
            sps[4].Value = fp.Statues;
            sps[5] = new SqlParameter("@CarNum", SqlDbType.NChar, 50);
            sps[5].Value = fp.CarNum;

            string strSQL = "select distinct(A.FID) 车辆FID,A.FBillNo 过磅编号,A.FText 车牌号码,A.FDecimal4 计划预装,A.FDecimal 进厂重量,A.FDecimal1 出厂重量,A.FDecimal2 实际净重,A.FDecimal3 出库数量,A.FComboBox 称量状态,A.FComboBox2 过磅类型,A.FTime 开票时间,A.FTime1 进厂时间,A.FTime2 出厂时间,A.FText8 磁卡,A.FText12 发货授权编号,B.FName 客户,C.FName 产品,A.FText1 开票人员,A.FText2 进厂司磅,A.FText3 出厂司磅,A.FDecimal19 盈亏,A.FText9 签发人员,D.FName 销售车辆,A.FComboBox3 生产线, A.FCheckBox4 作废标志 from KEW_SalesInfo A ";
            strSQL = strSQL + "left join t_Organization B on B.FItemID=A.FBase1 ";
            strSQL = strSQL + "left join KEW_Products C on C.FID=A.FBase ";
            strSQL = strSQL + "left join KEW_SalesCar D on D.FID=A.FBase3 ";
            strSQL = strSQL + "left join KEW_SalesInfoEntry E on E.FID=A.FID ";
            strSQL = strSQL + "left join KEW_SaleOrderQty F on F.FID=E.FID_SRC ";
            strSQL = strSQL + "left join KEW_SalesGuests G on G.FID=F.FID_SRC ";
            strSQL = strSQL + "where (F.FID=@FID or @FID='') and G.FBillNo=@FBillNo and (A.FComboBox=@Statues or @Statues='') and (A.FText like '%'+@BillNo+'%' or @BillNo='') and (A.FTime2>=@StartTime or @StartTime='') and (A.FTime2<=@EndTime or @EndTime='') order by A.FID desc";

            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                strResult = "";
                return strResult;
            }

            if (rs.Data.Tables[0].Rows.Count % fp.PageSize == 0)
            {
                nTotalPages = rs.Data.Tables[0].Rows.Count / fp.PageSize;
            }
            else
            {
                nTotalPages = rs.Data.Tables[0].Rows.Count / fp.PageSize + 1;
            }

            foreach (DataTable dt in rs.Data.Tables)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    if ((fp.PageSize * fp.Page >= nCount) && ((fp.Page - 1) * fp.PageSize < nCount))
                    {
                        SalesCarInfor orderInfor = new SalesCarInfor();
                        orderInfor.FID = dr[0].ToString();
                        orderInfor.WeighNumber = dr[1].ToString();
                        orderInfor.CarNumber = dr[2].ToString();
                        orderInfor.PreviousPlan = Math.Round(Common.CDec(dr[3].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.InWeight = Math.Round(Common.CDec(dr[4].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.OutWeight = Math.Round(Common.CDec(dr[5].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.FactNetWeight = Math.Round(Common.CDec(dr[6].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.OutStorage = Math.Round(Common.CDec(dr[7].ToString()), Common.QtyPrecision).ToString();

                        strQuery = dr[8].ToString().Trim();
                        if (Convert.ToInt32(strQuery) == 0)
                        {
                            orderInfor.WeighStatues = "开票";
                        }
                        else if (Convert.ToInt32(strQuery) == 1)
                        {
                            orderInfor.WeighStatues = "已开票";
                        }
                        else if (Convert.ToInt32(strQuery) == 2)
                        {
                            orderInfor.WeighStatues = "已进厂计量";
                        }
                        else if (Convert.ToInt32(strQuery) == 3)
                        {
                            orderInfor.WeighStatues = "计量完成";
                        }
                        else if (Convert.ToInt32(strQuery) == -1)
                        {
                            orderInfor.WeighStatues = "已发货授权";
                        }

                        strQuery = dr[24].ToString().Trim();
                        if (Convert.ToBoolean(strQuery))
                        {
                            orderInfor.WeighStatues = "已作废";
                        }

                        strQuery = dr[9].ToString().Trim();
                        if (Convert.ToInt32(strQuery) == 0)
                        {
                            orderInfor.WeighType = "正常过磅";
                        }
                        else if (Convert.ToInt32(strQuery) == 1)
                        {
                            orderInfor.WeighType = "退货";
                        }
                        else if (Convert.ToInt32(strQuery) == 2)
                        {
                            orderInfor.WeighType = "空车出厂";
                        }

                        orderInfor.TicketTime = dr[10].ToString();
                        orderInfor.InTime = dr[11].ToString();
                        orderInfor.OutTime = dr[12].ToString();
                        orderInfor.CardNum = dr[13].ToString();
                        orderInfor.OrderNumber = dr[14].ToString();
                        orderInfor.ClientName = dr[15].ToString();
                        orderInfor.ProductName = dr[16].ToString();
                        orderInfor.BillingMan = dr[17].ToString();
                        orderInfor.InSiBang = dr[18].ToString();
                        orderInfor.OutSiBang = dr[19].ToString();
                        orderInfor.ProfitAndLoss = Math.Round(Common.CDec(dr[20].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.SignMan = dr[21].ToString();
                        orderInfor.SalesCar = dr[22].ToString();
                        orderInfor.ProduceNumber = dr[23].ToString();
                        orderInfor.TotalPages = nTotalPages;
                        ht.Add(orderInfor);
                    }

                    if (nCount == fp.PageSize * fp.Page)
                    {
                        break;
                    }
                    nCount++;
                }
            }

            strResult = handler.Json.ClassToJson(ht);

            return strResult;
        }
    }

    //所有订单信息
    public class A14 : IMobileChild
    {
        public string Code(IMobile handler, ClientUser user, String parameter)
        {
            string strResult = "";
            int nCount = 1;
            int nTotalPages = 0;
            // Dictionary<string, SalesOrderInfor> ht = new Dictionary<string, SalesOrderInfor>();
            List<SalesOrderInfor> ht = new List<SalesOrderInfor>();

            FunctionParameter fp = new FunctionParameter();

            fp = (FunctionParameter)handler.Json.JsonToClass(parameter, typeof(FunctionParameter));

            SqlParameter[] sps = new SqlParameter[3];
            sps[0] = new SqlParameter("@FBillNo", SqlDbType.NChar, 50);
            sps[0].Value = user.UserName;
            sps[1] = new SqlParameter("@StartTime", SqlDbType.NChar, 50);
            sps[1].Value = fp.StartTime;
            sps[2] = new SqlParameter("@EndTime", SqlDbType.NChar, 50);
            sps[2].Value = fp.EndTime;

            //string strSQL = "select A.FID 订单FID,A.FBillNo 订单编号,D.FName 客户,B.FName 产品,A.FDecimal 数量,A.FDecimal3 含税单价,A.FDecimal7 含税运价,A.FDecimal8 运输金额,A.FDecimal4 含税金额,A.FDecimal9 总金额,A.FDate 下单日期,A.FDecimal10 已用数量,A.FDecimal12 已用金额,A.FDecimal5 运输单价,A.FDecimal6 运费税率,A.FDecimal1 单价,A.FDecimal2 税率,F.FName 袋装标准,G.FName 计量方案,A.FDecimal11 余量,C.FName 业务员,A.FDecimal13 其它单价,A.FDecimal14 其它金额,H.FName 销售方式,E.FName 结算方式 from KEW_SaleOrderQty A ";
            // strSQL = strSQL + "left join KEW_Products B on B.FID=A.FBase4 ";
            string strSQL = "select A.FID 订单FID,A.FBillNo 订单编号,D.FName 客户,B.FName 产品,A.FDecimal 数量,A.FDecimal3 含税单价,A.FDecimal7 含税运价,A.FDecimal8 运输金额,A.FDecimal4 含税金额,A.FDecimal9 总金额,A.FDate 下单日期,A.FDecimal10 已用数量,A.FDecimal12 已用金额,A.FDecimal5 运输单价,A.FDecimal6 运费税率,A.FDecimal1 单价,A.FDecimal2 税率,F.FName 袋装标准,G.FName 计量方案,A.FDecimal11 余量,C.FName 业务员,A.FDecimal13 其它单价,A.FDecimal14 其它金额,H.FName 销售方式,E.FName 结算方式 ,B.FCheckBox 是否袋装,F.FDecimal 每袋重量,B.FID 产品FID from KEW_SaleOrderQty A ";
            strSQL = strSQL + "left join KEW_ProductsEntry B on B.FID=A.FBase4 ";
            strSQL = strSQL + "left join t_Emp C on C.FItemID=A.FBase6 ";
            strSQL = strSQL + "left join t_Organization D on D.FItemID=A.FBase ";
            strSQL = strSQL + "left join t_Settle E on E.FItemID=A.FBase8 ";
            //strSQL = strSQL + "left join KEW_ProductsBagRule F on F.FParentID=A.FBase3 ";
            strSQL = strSQL + "left join KEW_ProductsBagRuleEntry F on F.FID=A.FBase3 ";
            strSQL = strSQL + "left join KEW_SalesConfig G on G.FID=A.FBase5 ";
            strSQL = strSQL + "left join t_SubMessage H on H.FInterID=A.FComboBox1 ";
            strSQL = strSQL + "left join KEW_SalesGuests I on I.FID=A.FID_SRC ";
            strSQL = strSQL + "where I.FBillNo=@FBillNo and A.FDecimal11>0 and (A.FDate>=@StartTime or @StartTime='') and (A.FDate<=@EndTime or @EndTime='') and A.FMultiCheckStatus='16' and A.FCheckBox=0 order by A.FID desc";


            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                strResult = "";
                return strResult;
            }

            if (rs.Data.Tables[0].Rows.Count % fp.PageSize == 0)
            {
                nTotalPages = rs.Data.Tables[0].Rows.Count / fp.PageSize;
            }
            else
            {
                nTotalPages = rs.Data.Tables[0].Rows.Count / fp.PageSize + 1;
            }

            foreach (DataTable dt in rs.Data.Tables)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    if ((fp.PageSize * fp.Page >= nCount) && ((fp.Page - 1) * fp.PageSize < nCount))
                    {
                        SalesOrderInfor orderInfor = new SalesOrderInfor();
                        orderInfor.FID = dr[0].ToString();
                        orderInfor.FBillNo = dr[1].ToString();
                        orderInfor.ClientName = dr[2].ToString();
                        orderInfor.ProductName = dr[3].ToString();
                        orderInfor.Amount = Math.Round(Common.CDec(dr[4].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.TaxPrice = Math.Round(Common.CDec(dr[5].ToString()), Common.PricePrecision).ToString();
                        orderInfor.TaxTransatePrice = Math.Round(Common.CDec(dr[6].ToString()), Common.PricePrecision).ToString();
                        orderInfor.TransateMoney = Math.Round(Common.CDec(dr[7].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.TaxMoney = Math.Round(Common.CDec(dr[8].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.TotalMoney = Math.Round(Common.CDec(dr[9].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.OrderDate = dr[10].ToString();
                        orderInfor.UsedNumber = Math.Round(Common.CDec(dr[11].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.UsedMoney = Math.Round(Common.CDec(dr[12].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.TransatePrice = Math.Round(Common.CDec(dr[13].ToString()), Common.PricePrecision).ToString();
                        orderInfor.TaxTransateRate = Math.Round(Common.CDec(dr[14].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.Price = Math.Round(Common.CDec(dr[15].ToString()), Common.PricePrecision).ToString();
                        orderInfor.TaxRate = Math.Round(Common.CDec(dr[16].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.BagStandard = dr[17].ToString();
                        orderInfor.MeasurementPlan = dr[18].ToString();
                        orderInfor.Allowance = Math.Round(Common.CDec(dr[19].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.SalesMan = dr[20].ToString();
                        orderInfor.OtherPrice = Math.Round(Common.CDec(dr[21].ToString()), Common.PricePrecision).ToString();
                        orderInfor.OtherMoney = Math.Round(Common.CDec(dr[22].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.SalesWay = dr[23].ToString();
                        orderInfor.SettleWay = dr[24].ToString();
                        orderInfor.IsBag = dr[25].ToString();
                        orderInfor.BagWeight = dr[26].ToString();
                        orderInfor.ProFID = dr[27].ToString();
                        orderInfor.TotalPages = nTotalPages;
                        ht.Add(orderInfor);

                    }

                    if (nCount == fp.PageSize * fp.Page)
                    {
                        break;
                    }
                    nCount++;
                }
            }

            strResult = handler.Json.ClassToJson(ht);
            return strResult;
        }
    }
}
